package com.example.position.demo.web;

import com.example.position.demo.entity.User;
import com.example.position.demo.service.UserService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

/**
 * @Author zhaoerqi
 * @Date 8/27/21
 */
@RestController
public class UserCtrl {

    @Autowired
    private UserService userService;

    @RequestMapping("/")
    public List<User> findUserList(){
        return userService.findList();
    }

    @RequestMapping("/save")
    public User save(@RequestBody User user){
        return userService.save(user);
    }

    @RequestMapping("/delete")
    public String deleteUser(@RequestParam String id){
        userService.delete(id);
        return "success";
    }

}
